// KDcom.h: interface for the KDcom class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_KDCOM_H__3454A223_6CF6_46CB_9E2F_3D1DED4CF9A7__INCLUDED_)
#define AFX_KDCOM_H__3454A223_6CF6_46CB_9E2F_3D1DED4CF9A7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Activcard_i.c"
#include "Activcard.h"
#include "Filter.h"

class KDcom  
{
public:
	long KDcom::DComGetPassword(const CString& strUsername, UINT& nPasswordID, long& lType);
	CString DComGetStaticPassword(const UINT& nPasswordID);
	void DComSetDeadline(const UINT& nPasswordID, const COleDateTime& dDeadline);
	COleDateTime DComGetDeadline(const UINT& nPasswordID);
	void DComSetLimitedTimes(const UINT& nPasswordID, const UINT& nTimes);
	UINT DComGetLeftTimes(const UINT& nPasswordID);
	BOOL DComIsPastDue(const UINT& nPasswordID);
	int DComUpdateToken(const CString &strSn, const BYTE * const pbySdbData, const int &iDataLen);
	void DcomGetTokensInfo(int &iTotal, int &iInUse, int &iIdel, int &iDisabled, int &iAssignedUser);
	BOOL DComGetSearchResultsPage(const CFilter &filter, ULONG ulPageNo, ULONG &ulPageSize, ULONG &ulPagesCount, CString &bstrPageData);
	BOOL DComIsExistMiniToken();
	BOOL DComIsMiniToken(const CString &strSn);
	int DComSetPinCode(const CString &strSn, const CString &strPinCode);
	enum PINPos
	{
		PIN_NONE	= 0,
		PIN_AFTER	= 1,
		PIN_BEFRORE	= 2
	};
	int DComGetMiniTokenPINPolicy(CString &strDefPIN, int &iPINPosition, int &iMinPINCodeLen, int &iMaxPINCodeLen, BOOL &ifAlwaysSetPin);
	int DComSetMiniTokenPINPolicy(CString strDefPIN, int iPINPosition, int iMinPINCodeLen, int iMaxPINCodeLen, BOOL ifAlwaysSetPin);
	int DComSetRadiusPort(CString strType,CString strPort);
	int DComGetAuthPort();
	int DComGetAcctPort();
	int DComGetIpList(CString &strList);
	int DComUpdateRadIp(CString strOldIp,CString strNewIp,  CString strNewDesc,  CString strNewKey);
	int DComDelRadIp(CString strIp);
	int DComAddRadIp(CString strIp,CString strDesc,CString strKey);
	int DComGetSysLog(CString strUser,CString strBtime,CString strEtime,CString &strLogList);
	int DComGetUserLicenses();
	int DComUpdatePwd(CString strUser,CString strPwd);
	int DComWriteKeyFile(char * pstrKey,int len);
	int DComDeleteSDB(CString strSn);
	int DComGetToken(CString strSn,unsigned char * outBuf,int * outLen);
	int DComGetSysPwd(CString strUser,CString strPwd,CString & strRights);
	int DComSycAuthTest(CString strSn,CString strPwd);
	int DComSycByCount(CString strSn,CString strValue);
	int DComSycByClock(CString strSn,CString strValue);
	int DComSycByOTP(CString strSn,CString strValue);
	int DComGetUnlockCode(CString strSn,CString strPostCode, CString &strResp);
	int DComUpdateTokenState(CString strSn,CString strState);
	int  DComUpdateUserGroup(CString strOld,CString strNew);
	int  DComInitFromServer(const char * szHost);
	long DComAddToken(unsigned char *lpData,int len);
	int  DComUpdateUserInfo(CString strUserGroup, CString strNameOld, CString strNameNew,CString strDesc,CString strSnOld,CString strSnNew,CString strRights);
	int  DComGetUserListByGroup(CString strUserGroup,CString & strList);
	int  DComGetTokeList(CString &strList);
	int  DComDeleteUser(CString strUserGroup,CString strUser);
	int  DComAddUser(CString strUser, CString strUserDesc, CString strUserGroup, CString strSn,CString strSn1,CString strRights);
	int  DComDelUserGroup(CString strUserGroup);
	int  DComClose();
	int  DComGetUserGroupsList(CString &stUserGroupList);
	int  DComGetUserListBySn(CString strSn,CString &stUserList);
	int  DComAddUserGroup(CString strUserGroup);
	int  DComGetUserCountBySn(CString strSn);

	int  DComGetAllUsersBySn(CString strSn,CString &stUserList);
	int  DComGetOneUserBySn(CString strSn,CString &strUserGroup,CString &strUser,CString &strDesc);
	bool DComInit();

	KDcom();
	virtual ~KDcom();

private:
	HRESULT m_hr;
	IUnknown * m_pUnknown;
	IAuthentication * m_pAuthenTication;
   
   
};

#endif // !defined(AFX_KDCOM_H__3454A223_6CF6_46CB_9E2F_3D1DED4CF9A7__INCLUDED_)
